Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement is_zeroes for checking all-zero hex strings #16

Closed
wants to merge 1 commit into from

Conversation

borngraced
Copy link

This PR introduces is_zeroes helper function, which makes it easy to check if a hex string consists entirely of zeroes, with optional support for a "0x" prefix. This function will be helpful in scenarios where we need to verify if a given value is zeroed out, such as in blockchain, cryptographic where null values are often represented as zero-filled hex strings.

@DaniPopes
Copy link
Owner

Thanks, however I don't feel like this provides any benefit vs just implementing it locally with for example s.strip_prefix("0x").unwrap_or(s).bytes().all(|b| b == 0). Generally you deserialize into a byte array and can check it afterwards easier like s.iter().all(|&b| b == 0).

@DaniPopes DaniPopes closed this Nov 28, 2024
@borngraced borngraced deleted the add-is-zeroes branch November 28, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants